
<link type="text/css" media="screen" rel="stylesheet" href="<{$xoops_url}>/modules/kshop/include/colorbox.css" />
<link type="text/css" href="<{$xoops_url}>/modules/kshop/include/ui-lightness/jquery-ui-1.8.1.custom.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="<{$xoops_url}>/modules/kshop/admin/kshop_admin.css" />

<script type="text/javascript" src="<{$xoops_url}>/modules/<{$xoops_dirname}>/sorttable.js"></script>
<script type="text/javascript" src="<{$xoops_url}>/modules/kshop/libclasses/ImageManager/assets/dialog.js"></script>
<script type="text/javascript" src="<{$xoops_url}>/modules/kshop/libclasses/ImageManager/IMEStandalone.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="<{$xoops_url}>/modules/kshop/include/jquery-ui-1.8.1.custom.min.js"></script>
<script type="text/javascript" src="<{$xoops_url}>/modules/kshop/include/jquery.colorbox-min.js"></script>
<script type="text/javascript">

    //Create a new Imanager Manager, needs the directory where the manager is
    //and which language translation to use.
    var manager = new ImageManager('<{$xoops_url}>/modules/kshop/libclasses/ImageManager','en');

    //Image Manager wrapper. Simply calls the ImageManager
    ImageSelector =
        {
        //This is called when the user has selected a file
        //and clicked OK, see popManager in IMEStandalone to
        //see the parameters returned.
        update : function(params)
        {
            if(this.field && this.field.value != null)
            {
                this.field.value = params.f_file; //params.f_url
            }
        },
        //open the Image Manager, updates the textfield
        //value when user has selected a file.
        select: function(textfieldID)
        {
            this.field = document.getElementById(textfieldID);
            manager.popManager(this);
        }
    };

    
    $(document).ready(function() {
        $(".notice").hide();
        $(".catpopBut").colorbox({width:"60%", height:"500px", inline:true, href:"#inline_category"});
        // Tabs
        $('#tabs').tabs();

        $(".mylink").bind("click", function() {
            var catID=$(this).attr('myval');
            var action=$(this).attr('myaction');
            if (action=="edit") editCat(catID);
            if (action=="del") delCat(catID);
            return false;
        });

        /*
        $( "#tabs" ).tabs({
            select: function(event, ui) { $(".mytabs2").html("Add New"); }
        });
         */
        $('#tabs').bind('tabsselect', function(event, ui) {
            if (ui.index==0){
                $(".mytabs2").html("Add New");
                emptyForms();
            }
            // Objects available in the function context:
            //alert(ui.index ); //KAOTIK
            //ui.tab     // anchor element of the selected (clicked) tab
            // ui.panel   // element, that contains the selected/clicked tab contents
            // ui.index   // zero-based index of the selected (clicked) tab
        });


        $('#catForm').submit(function() {
            var cname=$('#c_name').val();
            var cid=$('#c_id').val();
            var cdesc=$('#c_desc').val();
            var corder=$('#c_order').val();
            var cimg=$('#c_img').val();
            var ccat=$('#categories').val();
            $.post("ajax.php", { c_name: cname, time: "2pm" },
            function(data){
                alert("Data Loaded: " + data);
            });
            return false;
        });
    });

    function editCat(catID){
        $(".notice").show().html('Loading');
        var jsonCat ="action=loadcat&catid="+catID;
        $.getJSON("ajax.php",jsonCat, function(json){
            $("#c_name").val(json.name);
            $("#c_order").val(json.order);
            $("#c_id").val(json.id);
            $("#c_desc").val(json.desc);
            $("#categories").val(json.parent);
        }); //End json
        $('#tabs').tabs( "select" , "tabs-2" );
        $(".mytabs2").html("Edit");
        $(".notice").hide();
    }

    function emptyForms(){
        $("#c_name").val('');
        $("#c_order").val('');
        $("#c_desc").val('');
    }
        
</script>


<form name="entryform" method="post" action="products.php">
    <input type="hidden" name="mode" value="<{$mode}>">
    <input type="hidden" name="id" value="<{$prodid}>">



    <div class="ksLeftCol">
        <div class="ksCatMenu ksround">
            <{$smarty.const.KS_CATEGORY}><br />
            <select name="categories" multiple size="5">
                <{foreach item=cat from=$cats}>
                <option value="<{$cat.id}>"><{$cat.name}></option>
                <{/foreach}>
            </select>


            <div id='catDiv'>
                <a class='catpopBut' href="#">Edit</a>
            </div>

        </div>
        <br />
        <div class="ksOptMenu ksround">
            <{$smarty.const.KS_SELLALLAVAIL}><br />
            <select name="p_options[]" multiple size="5">
                <{foreach item=option from=$options}>
                <option value="<{$option.id}>" <{$option.sel}>><{$option.name}></option>
                <{/foreach}>
            </select>
        </div>
        <br />
        <div class="ksBrndMenu ksround">
            <{$smarty.const.KS_SUBTABS_PRODBRANDS}><br />
            <select name="brands">
                <{foreach item=brand from=$brands}>
                <option value="<{$brand.id}>" <{$brand.sel}>><{$brand.name}></option>
                <{/foreach}>
            </select>
        </div>
        <br />
        <div class="ksImgMenu ksround">
            <{$smarty.const.KS_IMGMANGR}><br />
            <input type="text" id="file" class="selectFile" readonly="readonly" name="p_image" value="<{$p_image}>" size="14" />
            <input type="button" name="select" value=" File " onclick="ImageSelector.select('file');"/>

            <p>
                <img src="<{$xoops_url}>/modules/<{$xoops_dirname}>/images/products<{$p_thumb}>">
            </p>
        </div>
    </div>

    <div class="ksRightCol">

        <label><{$smarty.const.KS_PRODNUM}></label>
        <input type="text" name="p_item_nr" size=25 maxlength="12" value="<{$p_item_nr}>">
        <p>
            <label><{$smarty.const.KS_PRODNAME}></label>
            <input type="text" name="p_name" size=35 maxlength="36" value="<{$p_name}>">
        </p>
        <p>
            <label><{$smarty.const.KS_PRODNAME}></label>
            <{$smarty.const.KS_LONGTEXT}>
        </p>
        <p>
            <label><{$smarty.const.KS_PRICE}></label>
            <input type="text" name="p_price" size="10" maxlength="15" value="<{$p_price}>"> <{$currency}>
        </p>
        <p>
            <label><{$smarty.const.KS_SPECIALPRICE}></label>
            <input type="text" name="p_sp_price" size="10" maxlength="15" value="<{$p_sp_price}>"> <{$currency}>
        </p>
        <p>
            <label><{$smarty.const.KS_ACTIVE}></label>
            <input type="checkbox" name="p_show_me"<{$p_show_mecheck}>>
        </p>
        <p>
            <label><{$smarty.const.KS_SHOWIMAGE}></label>
            <input type="checkbox" name="p_show_img"<{$p_show_imgcheck}>>
        </p>
        <p>
            <label><{$smarty.const.KS_SPECIAL}></label>
            <input type="checkbox" name="p_has_special"<{$p_has_specialcheck}>>
        </p>
        <p>
            <label><{$smarty.const.KS_STYLE}></label>
            <input type="checkbox" name="p_has_style"<{$p_has_stylecheck}>>
        </p>
        <p>
            <input type="submit" value="<{$smarty.const.KS_SUBMIT}>">
        </p>
    </div>

</form>

<div style='display:none'>
    <div id='inline_category' style='padding:10px; background:#fff;'>
        <div class="notice">msg</div>
        <div id="tabs">
            <ul>
                <li><a class="mytabs1" href="#tabs-1">List</a></li>
                <li><a class="mytabs2" href="#tabs-2">Add New</a></li>
            </ul>
            <div id="tabs-1">
                <table class="sortable" id="cat_list" width="100%"  border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td><{$smarty.const.KS_ACTION}></td>
                        <td><{$smarty.const.KS_ID}></td>
                        <td><{$smarty.const.KS_CATEGORY}></td>
                        <td><{$smarty.const.KS_SUBCATEGORY}></td>
                        <td><{$smarty.const.KS_SORTORDER}></td>
                    </tr>
                    <{foreach item=cat from=$listcats}>
                    <tr class="<{cycle values="odd,even"}>">
                        <td>
                            <div class="catButt">
                                <a class="mylink" myval="<{$cat.id}>" myaction="edit" title="<{$smarty.const.KS_EDITCAT}>" href="#"><img src="<{$xoops_url}>/modules/<{$xoops_dirname}>/images/edit.png" width="14" height="15"></a>

                                <a class="mylink" myval="<{$cat.id}>" title="<{$smarty.const.KS_DELCAT}>" href="categories.php?mode=del&id=<{$cat.id}>" onClick="return confirm('<{$smarty.const.KS_CONFIRMDEL}>')"><img src="<{$xoops_url}>/modules/<{$xoops_dirname}>/images/del.png" width="14" height="15"></a>

                            </div>
                        </td>
                        <td><{$cat.id}></td>
                        <td><{$cat.name}></td>
                        <td><{$cat.parent}></td>
                        <td><{$cat.sort}></td>
                    </tr>
                    <{/foreach}>
                </table>

            </div>
            <form name="catForm" id="catForm" action="POST">
                <div id="tabs-2">
                    <div style="float: left; height:300px; margin-right: 30px;">
                        <select id="categories" name="categories" size="5">
                            <{foreach item=cat from=$cats}>
                            <option value="<{$cat.id}>" <{$cat.sel}>><{$cat.name}></option>
                            <{/foreach}>
                        </select>
                    </div>

                    <p>
                        <label><{$smarty.const.KS_SORTORDER}></label>
                        <input type="text" id="c_order" name="c_order" size="3" value="<{$order}>">
                    </p>
                    <p>
                        <label><{$smarty.const.KS_NAMENEWCAT}></label>
                        <input type="text" id="c_name" name="c_name" size="15" value="<{$name}>">
                    </p>
                    <p>
                        <label><{$smarty.const.KS_DESCRIPTION}></label>
                        <textarea name="c_desc" id="c_desc" rows="3" cols="10"></textarea>
                    </p>
                    <p>
                        <{$smarty.const.KS_CTIMGSLCTIMG}>
                        <input type="text" id="file" class="selectFile" name="c_image" value="<{$img}>" />
                        <input type="button" name="select" value=" File " onclick="ImageSelector.select('file');"/>
                    </p>
                    <p>
                        <input type="submit" value="<{$smarty.const.KS_SUBMIT}>">
                    </p>
                </div>
            </form>
        </div>

    </div>
</div>
